Remove usage of stock APIs in demo
authorWilliam Jon McCann <william.jon.mccann@gmail.com>
Fri, 21 Jun 2013 17:46:54 +0000 (13:46 -0400)
committerWilliam Jon McCann <william.jon.mccann@gmail.com>
Mon, 24 Jun 2013 18:50:01 +0000 (14:50 -0400)
With the exception of GtkAction.

28 files changed:
demos/gtk-demo/Makefile.am
demos/gtk-demo/application.c
demos/gtk-demo/application.ui
demos/gtk-demo/appwindow.c
demos/gtk-demo/button_box.c
demos/gtk-demo/changedisplay.c
demos/gtk-demo/clipboard.c
demos/gtk-demo/combobox.c
demos/gtk-demo/css_shadows.c
demos/gtk-demo/demo.gresource.xml
demos/gtk-demo/dialog.c
demos/gtk-demo/entry_buffer.c
demos/gtk-demo/entry_completion.c
demos/gtk-demo/expander.c
demos/gtk-demo/iconview.c
demos/gtk-demo/infobar.c
demos/gtk-demo/list_store.c
demos/gtk-demo/listbox.ui
demos/gtk-demo/main.c
demos/gtk-demo/makefile.msc.in
demos/gtk-demo/offscreen_window2.c
demos/gtk-demo/revealer.ui
demos/gtk-demo/search_entry.c
demos/gtk-demo/sizegroup.c
demos/gtk-demo/spinner.c
demos/gtk-demo/stock_browser.c [deleted file]
demos/gtk-demo/toolpalette.c
demos/gtk-demo/ui_manager.c

index fa74321e22733b2da38e202947e442db46babf09..a10e4f4931f2a5e33b75e097f1b5f47454bcf53f 100644 (file)
@@ -47,7 +47,6 @@ demos =                                               \
        sizegroup.c                             \
        spinner.c                               \
        stack.c                                 \
-       stock_browser.c                         \
        textview.c                              \
        textscroll.c                            \
        theming_style_classes.c                 \
index 31b1da09c602ceaa384bd31e84bfe46ac947b70f..048535aaa5e9d620eab621d30b8689674a591944 100644 (file)
@@ -155,40 +155,6 @@ activate_quit (GSimpleAction *action,
     }
 }
 
-static void
-register_stock_icons (void)
-{
-  static gboolean registered = FALSE;
-
-  if (!registered)
-    {
-      GdkPixbuf *pixbuf;
-      GtkIconFactory *factory;
-      GtkIconSet *icon_set;
-
-      static GtkStockItem items[] = {
-        { "demo-gtk-logo", "_GTK!", 0, 0, NULL }
-      };
-
-      registered = TRUE;
-
-      gtk_stock_add (items, G_N_ELEMENTS (items));
-
-      factory = gtk_icon_factory_new ();
-      gtk_icon_factory_add_default (factory);
-
-      pixbuf = gdk_pixbuf_new_from_resource ("/application/gtk-logo-24.png", NULL);
-
-      icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
-      gtk_icon_factory_add (factory, "demo-gtk-logo", icon_set);
-      gtk_icon_set_unref (icon_set);
-      g_object_unref (pixbuf);
-
-      /* Drop our reference to the factory, GTK will hold a reference. */
-      g_object_unref (factory);
-    }
-}
-
 static void
 update_statusbar (GtkTextBuffer *buffer,
                   GtkStatusbar  *statusbar)
@@ -376,8 +342,6 @@ main (int argc, char *argv[])
 
   gtk_init (NULL, NULL);
 
-  register_stock_icons ();
-
   app = gtk_application_new ("org.gtk.Demo", 0);
   settings = g_settings_new ("org.gtk.Demo");
 
index 708513439628a976fccf8cea42c93199d3d8c064..a0801f5de0552655c2872fbe3f97cc7c5acf1345 100644 (file)
@@ -8,12 +8,12 @@
         <property name="hexpand">True</property>
         <child>
           <object class="GtkMenuToolButton" id="menutool">
-            <property name="stock-id">gtk-open</property>
+            <property name="icon-name">document-open</property>
           </object>
         </child>
         <child>
           <object class="GtkToolButton" id="quit">
-            <property name="stock-id">gtk-quit</property>
+            <property name="icon-name">application-exit</property>
             <property name="action-name">app.quit</property>
           </object>
         </child>
@@ -22,7 +22,7 @@
         </child>
         <child>
           <object class="GtkToolButton" id="logo">
-            <property name="stock-id">demo-gtk-logo</property>
+            <property name="icon-name">applications-other</property>
             <property name="action-name">win.logo</property>
           </object>
         </child>
@@ -54,8 +54,8 @@
               <object class="GtkButton" id="button">
                 <property name="visible">True</property>
                 <property name="valign">center</property>
-                <property name="label">gtk-ok</property>
-                <property name="use-stock">True</property>
+                <property name="label" translatable="yes">_OK</property>
+                <property name="use_underline">True</property>
               </object>
             </child>
           </object>
index df4d06bb22b46110e63315747fdddbdcaac18100..155a0190139602fbdcba25b85ed01005f0c2b26f 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "config.h"
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 static GtkWidget *window = NULL;
@@ -177,10 +178,6 @@ static GtkActionEntry entries[] = {
     "_About", "<control>A",                    /* label, accelerator */
     "About",                                   /* tooltip */
     G_CALLBACK (about_cb) },
-  { "Logo", "demo-gtk-logo",                   /* name, stock id */
-     NULL, NULL,                               /* label, accelerator */
-    "GTK+",                                    /* tooltip */
-    G_CALLBACK (activate_action) },
 };
 static guint n_entries = G_N_ELEMENTS (entries);
 
@@ -279,59 +276,9 @@ static const gchar *ui_info =
 "      </menu>"
 "    </toolitem>"
 "    <toolitem action='Quit'/>"
-"    <separator action='Sep1'/>"
-"    <toolitem action='Logo'/>"
 "  </toolbar>"
 "</ui>";
 
-
-
-/* This function registers our custom toolbar icons, so they can be themed.
- *
- * It's totally optional to do this, you could just manually insert icons
- * and have them not be themeable, especially if you never expect people
- * to theme your app.
- */
-static void
-register_stock_icons (void)
-{
-  static gboolean registered = FALSE;
-
-  if (!registered)
-    {
-      GdkPixbuf *pixbuf;
-      GtkIconFactory *factory;
-      GtkIconSet *icon_set;
-
-      static GtkStockItem items[] = {
-        { "demo-gtk-logo",
-          "_GTK!",
-          0, 0, NULL }
-      };
-
-      registered = TRUE;
-
-      /* Register our stock items */
-      gtk_stock_add (items, G_N_ELEMENTS (items));
-
-      /* Add our custom icon factory to the list of defaults */
-      factory = gtk_icon_factory_new ();
-      gtk_icon_factory_add_default (factory);
-
-      pixbuf = gdk_pixbuf_new_from_resource ("/appwindow/gtk-logo-old.png", NULL);
-      /* We assert the existence of the pixbuf as we load it from a custom resource. */
-      g_assert (pixbuf);
-
-      icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
-      gtk_icon_factory_add (factory, "demo-gtk-logo", icon_set);
-      gtk_icon_set_unref (icon_set);
-      g_object_unref (pixbuf);
-
-      /* Drop our reference to the factory, GTK will hold a reference. */
-      g_object_unref (factory);
-    }
-}
-
 static void
 update_statusbar (GtkTextBuffer *buffer,
                   GtkStatusbar  *statusbar)
@@ -387,8 +334,6 @@ do_appwindow (GtkWidget *do_widget)
       GtkUIManager *merge;
       GError *error = NULL;
 
-      register_stock_icons ();
-
       /* Create the toplevel window
        */
 
@@ -470,7 +415,7 @@ do_appwindow (GtkWidget *do_widget)
                           messagelabel,
                           TRUE, TRUE, 0);
       gtk_info_bar_add_button (GTK_INFO_BAR (infobar),
-                               GTK_STOCK_OK, GTK_RESPONSE_OK);
+                               _("OK"), GTK_RESPONSE_OK);
       g_signal_connect (infobar, "response",
                         G_CALLBACK (gtk_widget_hide), NULL);
 
index 798dc7cb822fec82e4c07658155b2e7b99fc8f93..3ad1707faf4f6d2bac782a2c63a09cd0f2c6aeb2 100644 (file)
@@ -3,6 +3,7 @@
  * The Button Box widgets are used to arrange buttons with padding.
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 static GtkWidget *
@@ -28,13 +29,13 @@ create_bbox (gint  horizontal,
   gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
   gtk_box_set_spacing (GTK_BOX (bbox), spacing);
 
-  button = gtk_button_new_from_stock (GTK_STOCK_OK);
+  button = gtk_button_new_with_label (_("OK"));
   gtk_container_add (GTK_CONTAINER (bbox), button);
 
-  button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+  button = gtk_button_new_with_label (_("Cancel"));
   gtk_container_add (GTK_CONTAINER (bbox), button);
 
-  button = gtk_button_new_from_stock (GTK_STOCK_HELP);
+  button = gtk_button_new_with_label (_("Help"));
   gtk_container_add (GTK_CONTAINER (bbox), button);
 
   return frame;
index 5997c703aaa0b94a10c3fa994b337879f61c59a4..7525d8a8e593138dd62bb0f7059da7ddf752aea7 100644 (file)
@@ -29,6 +29,7 @@
 
 #undef GDK_DISABLE_DEPRECATED
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 /* The ChangeDisplayInfo structure corresponds to a toplevel window and
@@ -211,8 +212,8 @@ open_display_cb (GtkWidget         *button,
   dialog = gtk_dialog_new_with_buttons ("Open Display",
                                         GTK_WINDOW (info->window),
                                         GTK_DIALOG_MODAL,
-                                        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                        GTK_STOCK_OK, GTK_RESPONSE_OK,
+                                        _("_Cancel"), GTK_RESPONSE_CANCEL,
+                                        _("_OK"), GTK_RESPONSE_OK,
                                         NULL);
 
   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
@@ -528,7 +529,7 @@ do_changedisplay (GtkWidget *do_widget)
       info->window = gtk_dialog_new_with_buttons ("Change Screen or display",
                                             GTK_WINDOW (do_widget),
                                             0,
-                                            GTK_STOCK_CLOSE,  GTK_RESPONSE_CLOSE,
+                                            _("_Close"),  GTK_RESPONSE_CLOSE,
                                             "Change",         GTK_RESPONSE_OK,
                                             NULL);
 
index 9497403545c81f427ffbd81dd607f1144fd3701d..fdf25fa13b9eb098ff7bbdaf2f8bd8819d1518c0 100644 (file)
@@ -9,6 +9,7 @@
  * manager to run.
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <string.h>
 
@@ -68,17 +69,24 @@ paste_button_clicked (GtkWidget *button,
 static GdkPixbuf *
 get_image_pixbuf (GtkImage *image)
 {
-  gchar *stock_id;
+  gchar *icon_name;
   GtkIconSize size;
+  GtkIconTheme *icon_theme;
+  int width;
 
   switch (gtk_image_get_storage_type (image))
     {
     case GTK_IMAGE_PIXBUF:
       return g_object_ref (gtk_image_get_pixbuf (image));
-    case GTK_IMAGE_STOCK:
-      gtk_image_get_stock (image, &stock_id, &size);
-      return gtk_widget_render_icon_pixbuf (GTK_WIDGET (image),
-                                            stock_id, size);
+    case GTK_IMAGE_ICON_NAME:
+      gtk_image_get_icon_name (image, &icon_name, &size);
+      icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (image));
+      gtk_icon_size_lookup (size, &width, NULL);
+      return gtk_icon_theme_load_icon (icon_theme,
+                                       icon_name,
+                                       width,
+                                       GTK_ICON_LOOKUP_GENERIC_FALLBACK,
+                                       NULL);
     default:
       g_warning ("Image storage type %d not handled",
                  gtk_image_get_storage_type (image));
@@ -177,12 +185,12 @@ button_press (GtkWidget      *widget,
 
   menu = gtk_menu_new ();
 
-  item = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY, NULL);
+  item = gtk_menu_item_new_with_mnemonic (_("_Copy"));
   g_signal_connect (item, "activate", G_CALLBACK (copy_image), data);
   gtk_widget_show (item);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 
-  item = gtk_image_menu_item_new_from_stock (GTK_STOCK_PASTE, NULL);
+  item = gtk_menu_item_new_with_mnemonic (_("_Paste"));
   g_signal_connect (item, "activate", G_CALLBACK (paste_image), data);
   gtk_widget_show (item);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
@@ -228,7 +236,7 @@ do_clipboard (GtkWidget *do_widget)
       gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
 
       /* Create the button */
-      button = gtk_button_new_from_stock (GTK_STOCK_COPY);
+      button = gtk_button_new_with_mnemonic (_("_Copy"));
       gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
       g_signal_connect (button, "clicked",
                         G_CALLBACK (copy_button_clicked), entry);
@@ -245,7 +253,7 @@ do_clipboard (GtkWidget *do_widget)
       gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
 
       /* Create the button */
-      button = gtk_button_new_from_stock (GTK_STOCK_PASTE);
+      button = gtk_button_new_with_mnemonic (_("_Paste"));
       gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
       g_signal_connect (button, "clicked",
                         G_CALLBACK (paste_button_clicked), entry);
@@ -258,8 +266,8 @@ do_clipboard (GtkWidget *do_widget)
       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
       /* Create the first image */
-      image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
-                                        GTK_ICON_SIZE_BUTTON);
+      image = gtk_image_new_from_icon_name ("dialog-warning",
+                                            GTK_ICON_SIZE_BUTTON);
       ebox = gtk_event_box_new ();
       gtk_container_add (GTK_CONTAINER (ebox), image);
       gtk_container_add (GTK_CONTAINER (hbox), ebox);
@@ -284,8 +292,8 @@ do_clipboard (GtkWidget *do_widget)
                         G_CALLBACK (button_press), image);
 
       /* Create the second image */
-      image = gtk_image_new_from_stock (GTK_STOCK_STOP,
-                                        GTK_ICON_SIZE_BUTTON);
+      image = gtk_image_new_from_icon_name ("process-stop",
+                                            GTK_ICON_SIZE_BUTTON);
       ebox = gtk_event_box_new ();
       gtk_container_add (GTK_CONTAINER (ebox), image);
       gtk_container_add (GTK_CONTAINER (hbox), ebox);
index 354fcab0d87e4b6100ffb71a314d476c2d260d80..e76413845ee83d702baa83ed9f79f2ec4cd708ee 100644 (file)
@@ -7,81 +7,59 @@
  * How the options are displayed is controlled by cell renderers.
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 enum
 {
-  PIXBUF_COL,
+  ICON_NAME_COL,
   TEXT_COL
 };
 
-static gchar *
-strip_underscore (const gchar *text)
-{
-  gchar *p, *q;
-  gchar *result;
-
-  result = g_strdup (text);
-  p = q = result;
-  while (*p)
-    {
-      if (*p != '_')
-        {
-          *q = *p;
-          q++;
-        }
-      p++;
-    }
-  *q = '\0';
-
-  return result;
-}
-
 static GtkTreeModel *
-create_stock_icon_store (void)
+create_icon_store (void)
 {
-  gchar *stock_id[6] = {
-    GTK_STOCK_DIALOG_WARNING,
-    GTK_STOCK_STOP,
-    GTK_STOCK_NEW,
-    GTK_STOCK_CLEAR,
+  const gchar *icon_names[6] = {
+    "dialog-warning",
+    "process-stop",
+    "document-new",
+    "edit-clear",
+    NULL,
+    "document-open"
+  };
+  const gchar *labels[6] = {
+    N_("Warning"),
+    N_("Stop"),
+    N_("New"),
+    N_("Clear"),
     NULL,
-    GTK_STOCK_OPEN
+    N_("Open")
   };
 
-  GtkStockItem item;
-  GdkPixbuf *pixbuf;
   GtkWidget *cellview;
   GtkTreeIter iter;
   GtkListStore *store;
-  gchar *label;
   gint i;
 
   cellview = gtk_cell_view_new ();
 
-  store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
+  store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
 
-  for (i = 0; i < G_N_ELEMENTS (stock_id); i++)
+  for (i = 0; i < G_N_ELEMENTS (icon_names); i++)
     {
-      if (stock_id[i])
+      if (icon_names[i])
         {
-          pixbuf = gtk_widget_render_icon_pixbuf (cellview, stock_id[i],
-                                                  GTK_ICON_SIZE_BUTTON);
-          gtk_stock_lookup (stock_id[i], &item);
-          label = strip_underscore (item.label);
           gtk_list_store_append (store, &iter);
           gtk_list_store_set (store, &iter,
-                              PIXBUF_COL, pixbuf,
-                              TEXT_COL, label,
+                              ICON_NAME_COL, icon_names[i],
+                              TEXT_COL, _(labels[i]),
                               -1);
-          g_object_unref (pixbuf);
-          g_free (label);
         }
       else
         {
           gtk_list_store_append (store, &iter);
           gtk_list_store_set (store, &iter,
-                              PIXBUF_COL, NULL,
+                              ICON_NAME_COL, NULL,
                               TEXT_COL, "separator",
                               -1);
         }
@@ -351,14 +329,14 @@ do_combobox (GtkWidget *do_widget)
     /* A combobox demonstrating cell renderers, separators and
      *  insensitive rows
      */
-    frame = gtk_frame_new ("Some stock icons");
+    frame = gtk_frame_new ("Items with icons");
     gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
     box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
     gtk_container_set_border_width (GTK_CONTAINER (box), 5);
     gtk_container_add (GTK_CONTAINER (frame), box);
 
-    model = create_stock_icon_store ();
+    model = create_icon_store ();
     combo = gtk_combo_box_new_with_model (model);
     g_object_unref (model);
     gtk_container_add (GTK_CONTAINER (box), combo);
@@ -366,7 +344,7 @@ do_combobox (GtkWidget *do_widget)
     renderer = gtk_cell_renderer_pixbuf_new ();
     gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
     gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
-                                    "pixbuf", PIXBUF_COL,
+                                    "icon-name", ICON_NAME_COL,
                                     NULL);
 
     gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
index 2ee2fec5cbd2ee615d768673679786e67972f31f..590c0f3f00be062b072f4335f6684bf09c88a504 100644 (file)
@@ -68,10 +68,12 @@ create_toolbar (void)
   toolbar = gtk_toolbar_new ();
   gtk_widget_set_valign (toolbar, GTK_ALIGN_CENTER);
 
-  item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
+  item = gtk_tool_button_new (NULL, NULL);
+  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-next");
   gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
 
-  item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_BACK);
+  item = gtk_tool_button_new (NULL, NULL);
+  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-previous");
   gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
 
   item = gtk_tool_button_new (NULL, "Hello World");
index f281a59b1ecec45d5407fe11f9f6d444325028fd..fb9c52a775d86abbbffe3a1553164a4586caea36 100644 (file)
     <file>sizegroup.c</file>
     <file>stack.c</file>
     <file>spinner.c</file>
-    <file>stock_browser.c</file>
     <file>textview.c</file>
     <file>textscroll.c</file>
     <file>theming_style_classes.c</file>
index d9bc98db31b7a65e7c5ca31298a7806a6dbb3f02..17f837e8f8bc5a2c7394918656d5999440e5da11 100644 (file)
@@ -3,6 +3,7 @@
  * Dialog widgets are used to pop up a transient window for user feedback.
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 static GtkWidget *window = NULL;
@@ -36,7 +37,7 @@ interactive_dialog_clicked (GtkButton *button,
   GtkWidget *content_area;
   GtkWidget *dialog;
   GtkWidget *hbox;
-  GtkWidget *stock;
+  GtkWidget *image;
   GtkWidget *table;
   GtkWidget *local_entry1;
   GtkWidget *local_entry2;
@@ -46,9 +47,9 @@ interactive_dialog_clicked (GtkButton *button,
   dialog = gtk_dialog_new_with_buttons ("Interactive Dialog",
                                         GTK_WINDOW (window),
                                         GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT,
-                                        GTK_STOCK_OK,
+                                        _("_OK"),
                                         GTK_RESPONSE_OK,
-                                        "_Non-stock Button",
+                                        "_Cancel",
                                         GTK_RESPONSE_CANCEL,
                                         NULL);
 
@@ -58,8 +59,8 @@ interactive_dialog_clicked (GtkButton *button,
   gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
   gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 0);
 
-  stock = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
-  gtk_box_pack_start (GTK_BOX (hbox), stock, FALSE, FALSE, 0);
+  image = gtk_image_new_from_icon_name ("dialog-question", GTK_ICON_SIZE_DIALOG);
+  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
 
   table = gtk_grid_new ();
   gtk_grid_set_row_spacing (GTK_GRID (table), 4);
index 4d7b704b65584d8d726ba5945eea98fa4ca85e9e..67a4b2f27a3dfef6cad5ea11e47cc0b71dbfc6b3 100644 (file)
@@ -4,6 +4,7 @@
  *
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 static GtkWidget *window = NULL;
@@ -22,7 +23,7 @@ do_entry_buffer (GtkWidget *do_widget)
     window = gtk_dialog_new_with_buttons ("GtkEntryBuffer",
                                           GTK_WINDOW (do_widget),
                                           0,
-                                          GTK_STOCK_CLOSE,
+                                          _("_Close"),
                                           GTK_RESPONSE_NONE,
                                           NULL);
     gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
index ce218ed00c3dd21c614b243a4a36cd124205f4bf..fb71c672cf198d9b8a1d89545339ea33939dce1f 100644 (file)
@@ -5,6 +5,7 @@
  *
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 static GtkWidget *window = NULL;
@@ -49,7 +50,7 @@ do_entry_completion (GtkWidget *do_widget)
       window = gtk_dialog_new_with_buttons ("GtkEntryCompletion",
                                             GTK_WINDOW (do_widget),
                                             0,
-                                            GTK_STOCK_CLOSE,
+                                            _("_Close"),
                                             GTK_RESPONSE_NONE,
                                             NULL);
       gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
index 423a8131fe7846b13e8486d0b5f41c825c6c7f91..6228bfd6f76dc98cee29fa261a868ee85b0f7aff 100644 (file)
@@ -5,6 +5,7 @@
  *
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 static GtkWidget *window = NULL;
@@ -23,7 +24,7 @@ do_expander (GtkWidget *do_widget)
     window = gtk_dialog_new_with_buttons ("GtkExpander",
                                           GTK_WINDOW (do_widget),
                                           0,
-                                          GTK_STOCK_CLOSE,
+                                          _("_Close"),
                                           GTK_RESPONSE_NONE,
                                           NULL);
     gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
index d54527b1f36022ac4426b95a4c302cafb2374281..8af65f5d83425e95f19535b2b6ce0f4ffb77679a 100644 (file)
@@ -5,6 +5,7 @@
  * example might be helpful.
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <string.h>
 
@@ -267,12 +268,16 @@ do_iconview (GtkWidget *do_widget)
       tool_bar = gtk_toolbar_new ();
       gtk_box_pack_start (GTK_BOX (vbox), tool_bar, FALSE, FALSE, 0);
 
-      up_button = gtk_tool_button_new_from_stock (GTK_STOCK_GO_UP);
+      up_button = gtk_tool_button_new (NULL, NULL);
+      gtk_tool_button_set_label (GTK_TOOL_BUTTON (up_button), _("_Up"));
+      gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (up_button), "go-up");
       gtk_tool_item_set_is_important (up_button, TRUE);
       gtk_widget_set_sensitive (GTK_WIDGET (up_button), FALSE);
       gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), up_button, -1);
 
-      home_button = gtk_tool_button_new_from_stock (GTK_STOCK_HOME);
+      home_button = gtk_tool_button_new (NULL, NULL);
+      gtk_tool_button_set_label (GTK_TOOL_BUTTON (home_button), _("_Home"));
+      gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (home_button), "go-home");
       gtk_tool_item_set_is_important (home_button, TRUE);
       gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), home_button, -1);
 
index 0cb58e66b15d9dd9282a0639ebf8cdaea9935a99..0aea0648f1f3e3de1916f48d4e713bb662b3a7b5 100644 (file)
@@ -3,6 +3,7 @@
  * Info bar widgets are used to report important messages to the user.
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 static GtkWidget *window = NULL;
@@ -64,7 +65,7 @@ do_infobar (GtkWidget *do_widget)
       label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_WARNING");
       gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE, 0);
 
-      bar = gtk_info_bar_new_with_buttons (GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+      bar = gtk_info_bar_new_with_buttons (_("_OK"), GTK_RESPONSE_OK, NULL);
       g_signal_connect (bar, "response", G_CALLBACK (on_bar_response), window);
       gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 0);
       gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_QUESTION);
index e5d2dff42b9427deff74850c71884d07f673135b..343a3871908336a4028739692e48e8f9f0f748ad 100644 (file)
@@ -2,8 +2,7 @@
  *
  * The GtkListStore is used to store data in list form, to be used
  * later on by a GtkTreeView to display it. This demo builds a
- * simple GtkListStore and displays it. See the Stock Browser
- * demo for a more advanced example.
+ * simple GtkListStore and displays it.
  *
  */
 
index f2d8fca391924508817fe55f23ff93fb2e2cbac5..1d426014d30f477e749b39a1a1bdf9baec80fc29 100644 (file)
@@ -40,7 +40,7 @@
             <property name="margin_bottom">8</property>
             <property name="margin_left">8</property>
             <property name="margin_right">8</property>
-            <property name="stock">gtk-missing-image</property>
+            <property name="icon-name">image-missing</property>
           </object>
           <packing>
             <property name="left_attach">0</property>
index 69d3093639f5ccedbabc9b68c8eb2048031065d2..cf1a761a23ea5e656f0fb0c408075696159e047c 100644 (file)
@@ -122,7 +122,6 @@ static gchar *types[] =
   "GtkActionEntry ",
   "GtkRadioActionEntry ",
   "GtkIconFactory ",
-  "GtkStockItem ",
   "GtkIconSet ",
   "GtkTextBuffer ",
   "GtkStatusbar ",
index a92362f3afa620301c1e6261fae81b6e9f9d9d08..948269dc3865bc98008d76a7046968c2ddb09b86 100644 (file)
@@ -54,7 +54,6 @@ DEMOS = \
        pixbufs.c               \
        rotated_text.c  \
        sizegroup.c     \
-       stock_browser.c \
        textview.c      \
        tree_store.c    \
        ui_manager.c    \
@@ -83,7 +82,6 @@ OBJECTS = \
        pixbufs.obj     \
        rotated_text.obj \
        sizegroup.obj   \
-       stock_browser.obj       \
        textview.obj    \
        tree_store.obj  \
        ui_manager.obj  \
index b28270448b5d1296fc3b5fd6e2a470b0a9b4c4ed..9188bfbff6dae4b2b273bca35fda946b0863b616 100644 (file)
@@ -3,6 +3,7 @@
  * Offscreen windows can be used to render elements multiple times to achieve
  * various effects.
  */
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 #define GTK_TYPE_MIRROR_BIN              (gtk_mirror_bin_get_type ())
@@ -497,14 +498,12 @@ do_offscreen_window2 (GtkWidget *do_widget)
       hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
       backbutton = gtk_button_new ();
       gtk_container_add (GTK_CONTAINER (backbutton),
-                         gtk_image_new_from_stock (GTK_STOCK_GO_BACK, 4));
+                         gtk_image_new_from_icon_name ("go-previous", 4));
       gtk_size_group_add_widget (group, backbutton);
       entry = gtk_entry_new ();
       gtk_size_group_add_widget (group, entry);
-      applybutton = gtk_button_new ();
+      applybutton = gtk_button_new_with_label (_("Apply"));
       gtk_size_group_add_widget (group, applybutton);
-      gtk_container_add (GTK_CONTAINER (applybutton),
-                         gtk_image_new_from_stock (GTK_STOCK_APPLY, 4));
 
       gtk_container_add (GTK_CONTAINER (window), vbox);
       gtk_box_pack_start (GTK_BOX (vbox), bin, TRUE, TRUE, 0);
index 6449c984e565cd8fcab4c3985a5a6acbd4e8e45e..f1cbac007d4a9a81afc6cbfec85137f61d75dcf9 100644 (file)
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="button1">
-                <property name="label">gtk-close</property>
+                <property name="label" translatable="yes">_Close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
+                <property name="use_underline">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
index be03fc9725fbb4d411551fe16c3945bde55595c1..0a270d4f76cb428d548a1b38243d2a316d6fd9ac 100644 (file)
@@ -4,6 +4,7 @@
  * This demo shows how to use these features in a search entry.
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 static GtkWidget *window = NULL;
@@ -85,9 +86,6 @@ static void
 search_by_name (GtkWidget *item,
                 GtkEntry  *entry)
 {
-  gtk_entry_set_icon_from_stock (entry,
-                                 GTK_ENTRY_ICON_PRIMARY,
-                                 GTK_STOCK_FIND);
   gtk_entry_set_icon_tooltip_text (entry,
                                    GTK_ENTRY_ICON_PRIMARY,
                                    "Search by name\n"
@@ -99,9 +97,7 @@ static void
 search_by_description (GtkWidget *item,
                        GtkEntry  *entry)
 {
-  gtk_entry_set_icon_from_stock (entry,
-                                 GTK_ENTRY_ICON_PRIMARY,
-                                 GTK_STOCK_EDIT);
+
   gtk_entry_set_icon_tooltip_text (entry,
                                    GTK_ENTRY_ICON_PRIMARY,
                                    "Search by description\n"
@@ -113,9 +109,6 @@ static void
 search_by_file (GtkWidget *item,
                 GtkEntry  *entry)
 {
-  gtk_entry_set_icon_from_stock (entry,
-                                 GTK_ENTRY_ICON_PRIMARY,
-                                 GTK_STOCK_OPEN);
   gtk_entry_set_icon_tooltip_text (entry,
                                    GTK_ENTRY_ICON_PRIMARY,
                                    "Search by file name\n"
@@ -132,26 +125,17 @@ create_search_menu (GtkWidget *entry)
 
   menu = gtk_menu_new ();
 
-  item = gtk_image_menu_item_new_with_mnemonic ("Search by _name");
-  image = gtk_image_new_from_stock (GTK_STOCK_FIND, GTK_ICON_SIZE_MENU);
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-  gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+  item = gtk_menu_item_new_with_mnemonic ("Search by _name");
   g_signal_connect (item, "activate",
                     G_CALLBACK (search_by_name), entry);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 
-  item = gtk_image_menu_item_new_with_mnemonic ("Search by _description");
-  image = gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU);
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-  gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+  item = gtk_menu_item_new_with_mnemonic ("Search by _description");
   g_signal_connect (item, "activate",
                     G_CALLBACK (search_by_description), entry);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 
-  item = gtk_image_menu_item_new_with_mnemonic ("Search by _file name");
-  image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-  gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+  item = gtk_menu_item_new_with_mnemonic ("Search by _file name");
   g_signal_connect (item, "activate",
                     G_CALLBACK (search_by_file), entry);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
@@ -241,7 +225,7 @@ do_search_entry (GtkWidget *do_widget)
       window = gtk_dialog_new_with_buttons ("Search Entry",
                                             GTK_WINDOW (do_widget),
                                             0,
-                                            GTK_STOCK_CLOSE,
+                                            _("_Close"),
                                             GTK_RESPONSE_NONE,
                                             NULL);
       gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
index a0313963668155b91f4a24879346e4ce34ee9f5a..c15b78b9386cadf72dbacd50e7054a41d1c91f1a 100644 (file)
@@ -13,6 +13,7 @@
  * into a table, you would not include the GTK_FILL flag.
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 static GtkWidget *window = NULL;
@@ -102,7 +103,7 @@ do_sizegroup (GtkWidget *do_widget)
       window = gtk_dialog_new_with_buttons ("GtkSizeGroup",
                                             GTK_WINDOW (do_widget),
                                             0,
-                                            GTK_STOCK_CLOSE,
+                                            _("_Close"),
                                             GTK_RESPONSE_NONE,
                                             NULL);
       gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
index 8aa5173b0add9a08f771673798545e271c6c49f8..3e04ad843ce0c2e5af2153ee2ac81e9517036177 100644 (file)
@@ -4,6 +4,7 @@
  *
  */
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 static GtkWidget *window = NULL;
@@ -38,7 +39,7 @@ do_spinner (GtkWidget *do_widget)
     window = gtk_dialog_new_with_buttons ("GtkSpinner",
                                           GTK_WINDOW (do_widget),
                                           0,
-                                          GTK_STOCK_CLOSE,
+                                          _("_Close"),
                                           GTK_RESPONSE_NONE,
                                           NULL);
     gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
@@ -71,12 +72,12 @@ do_spinner (GtkWidget *do_widget)
     spinner_unsensitive = spinner;
     gtk_widget_set_sensitive (hbox, FALSE);
 
-    button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY);
+    button = gtk_button_new_with_label (_("Play"));
     g_signal_connect (G_OBJECT (button), "clicked",
                       G_CALLBACK (on_play_clicked), spinner);
     gtk_container_add (GTK_CONTAINER (vbox), button);
 
-    button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_STOP);
+    button = gtk_button_new_with_label (_("Stop"));
     g_signal_connect (G_OBJECT (button), "clicked",
                       G_CALLBACK (on_stop_clicked), spinner);
     gtk_container_add (GTK_CONTAINER (vbox), button);
diff --git a/demos/gtk-demo/stock_browser.c b/demos/gtk-demo/stock_browser.c
deleted file mode 100644 (file)
index 06ccb8c..0000000
+++ /dev/null
@@ -1,535 +0,0 @@
-/* Stock Item and Icon Browser
- *
- * This source code for this demo doesn't demonstrate anything
- * particularly useful in applications. The purpose of the "demo" is
- * just to provide a handy place to browse the available stock icons
- * and stock items.
- */
-
-#include <string.h>
-
-#include <gtk/gtk.h>
-
-static GtkWidget *window = NULL;
-
-typedef struct _StockItemInfo StockItemInfo;
-struct _StockItemInfo
-{
-  gchar *id;
-  GtkStockItem item;
-  GdkPixbuf *small_icon;
-  gchar *macro;
-  gchar *accel_str;
-};
-
-/* Make StockItemInfo a boxed type so we can automatically
- * manage memory
- */
-#define STOCK_ITEM_INFO_TYPE stock_item_info_get_type ()
-
-static void
-stock_item_info_free (StockItemInfo *info)
-{
-  g_free (info->id);
-  g_free (info->macro);
-  g_free (info->accel_str);
-  if (info->small_icon)
-    g_object_unref (info->small_icon);
-
-  g_free (info);
-}
-
-static StockItemInfo*
-stock_item_info_copy (StockItemInfo *src)
-{
-  StockItemInfo *info;
-
-  info = g_new (StockItemInfo, 1);
-  info->id = g_strdup (src->id);
-  info->macro = g_strdup (src->macro);
-  info->accel_str = g_strdup (src->accel_str);
-
-  info->item = src->item;
-
-  info->small_icon = src->small_icon;
-  if (info->small_icon)
-    g_object_ref (info->small_icon);
-
-  return info;
-}
-
-static
-G_DEFINE_BOXED_TYPE (StockItemInfo, stock_item_info,
-                     stock_item_info_copy,
-                     stock_item_info_free)
-
-typedef struct _StockItemDisplay StockItemDisplay;
-struct _StockItemDisplay
-{
-  GtkWidget *type_label;
-  GtkWidget *macro_label;
-  GtkWidget *id_label;
-  GtkWidget *label_accel_label;
-  GtkWidget *icon_image;
-};
-
-static gchar*
-id_to_macro (const gchar *id)
-{
-  GString *macro = NULL;
-  const gchar *cp;
-
-  /* gtk-foo-bar -> GTK_STOCK_FOO_BAR */
-
-  macro = g_string_new (NULL);
-
-  cp = id;
-
-  if (strncmp (cp, "gtk-", 4) == 0)
-    {
-      g_string_append (macro, "GTK_STOCK_");
-      cp += 4;
-    }
-
-  while (*cp)
-    {
-      if (*cp == '-')
-        g_string_append_c (macro, '_');
-      else if (g_ascii_islower (*cp))
-        g_string_append_c (macro, g_ascii_toupper (*cp));
-      else
-        g_string_append_c (macro, *cp);
-
-      cp++;
-    }
-
-  return g_string_free (macro, FALSE);
-}
-
-static GtkTreeModel*
-create_model (void)
-{
-  GtkListStore *store;
-  GSList *ids;
-  GSList *tmp_list;
-
-  store = gtk_list_store_new (2, STOCK_ITEM_INFO_TYPE, G_TYPE_STRING);
-
-  ids = gtk_stock_list_ids ();
-  ids = g_slist_sort (ids, (GCompareFunc) strcmp);
-  tmp_list = ids;
-  while (tmp_list != NULL)
-    {
-      StockItemInfo info;
-      GtkStockItem item;
-      GtkTreeIter iter;
-      GtkIconSet *icon_set;
-
-      info.id = tmp_list->data;
-
-      if (gtk_stock_lookup (info.id, &item))
-        {
-          info.item = item;
-        }
-      else
-        {
-          info.item.label = NULL;
-          info.item.stock_id = NULL;
-          info.item.modifier = 0;
-          info.item.keyval = 0;
-          info.item.translation_domain = NULL;
-        }
-
-      /* only show icons for stock IDs that have default icons */
-      icon_set = gtk_icon_factory_lookup_default (info.id);
-      if (icon_set)
-        {
-          GtkIconSize *sizes = NULL;
-          gint n_sizes = 0;
-          gint i;
-          GtkIconSize size;
-
-          /* See what sizes this stock icon really exists at */
-          gtk_icon_set_get_sizes (icon_set, &sizes, &n_sizes);
-
-          /* Use menu size if it exists, otherwise first size found */
-          size = sizes[0];
-          i = 0;
-          while (i < n_sizes)
-            {
-              if (sizes[i] == GTK_ICON_SIZE_MENU)
-                {
-                  size = GTK_ICON_SIZE_MENU;
-                  break;
-                }
-              ++i;
-            }
-          g_free (sizes);
-
-          info.small_icon = gtk_widget_render_icon_pixbuf (window,
-                                                           info.id,
-                                                           size);
-
-          if (size != GTK_ICON_SIZE_MENU)
-            {
-              /* Make the result the proper size for our thumbnail */
-              gint w, h;
-              GdkPixbuf *scaled;
-
-              gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
-
-              scaled = gdk_pixbuf_scale_simple (info.small_icon,
-                                                w, h,
-                                                GDK_INTERP_BILINEAR);
-
-              g_object_unref (info.small_icon);
-              info.small_icon = scaled;
-            }
-        }
-      else
-        info.small_icon = NULL;
-
-      if (info.item.keyval != 0)
-        {
-          info.accel_str = gtk_accelerator_name (info.item.keyval,
-                                                 info.item.modifier);
-        }
-      else
-        {
-          info.accel_str = g_strdup ("");
-        }
-
-      info.macro = id_to_macro (info.id);
-
-      gtk_list_store_append (store, &iter);
-      gtk_list_store_set (store, &iter, 0, &info, 1, info.id, -1);
-
-      g_free (info.macro);
-      g_free (info.accel_str);
-      if (info.small_icon)
-        g_object_unref (info.small_icon);
-
-      tmp_list = g_slist_next (tmp_list);
-    }
-
-  g_slist_foreach (ids, (GFunc)g_free, NULL);
-  g_slist_free (ids);
-
-  return GTK_TREE_MODEL (store);
-}
-
-/* Finds the largest size at which the given image stock id is
- * available. This would not be useful for a normal application
- */
-static GtkIconSize
-get_largest_size (const char *id)
-{
-  GtkIconSet *set = gtk_icon_factory_lookup_default (id);
-  GtkIconSize *sizes;
-  gint n_sizes, i;
-  GtkIconSize best_size = GTK_ICON_SIZE_INVALID;
-  gint best_pixels = 0;
-
-  gtk_icon_set_get_sizes (set, &sizes, &n_sizes);
-
-  for (i = 0; i < n_sizes; i++)
-    {
-      gint width, height;
-
-      gtk_icon_size_lookup (sizes[i], &width, &height);
-
-      if (width * height > best_pixels)
-        {
-          best_size = sizes[i];
-          best_pixels = width * height;
-        }
-    }
-
-  g_free (sizes);
-
-  return best_size;
-}
-
-static void
-selection_changed (GtkTreeSelection *selection)
-{
-  GtkTreeView *treeview;
-  StockItemDisplay *display;
-  GtkTreeModel *model;
-  GtkTreeIter iter;
-
-  treeview = gtk_tree_selection_get_tree_view (selection);
-  display = g_object_get_data (G_OBJECT (treeview), "stock-display");
-
-  if (gtk_tree_selection_get_selected (selection, &model, &iter))
-    {
-      StockItemInfo *info;
-      gchar *str;
-
-      gtk_tree_model_get (model, &iter,
-                          0, &info,
-                          -1);
-
-      if (info->small_icon && info->item.label)
-        gtk_label_set_text (GTK_LABEL (display->type_label), "Icon and Item");
-      else if (info->small_icon)
-        gtk_label_set_text (GTK_LABEL (display->type_label), "Icon Only");
-      else if (info->item.label)
-        gtk_label_set_text (GTK_LABEL (display->type_label), "Item Only");
-      else
-        gtk_label_set_text (GTK_LABEL (display->type_label), "???????");
-
-      gtk_label_set_text (GTK_LABEL (display->macro_label), info->macro);
-      gtk_label_set_text (GTK_LABEL (display->id_label), info->id);
-
-      if (info->item.label)
-        {
-          str = g_strdup_printf ("%s %s", info->item.label, info->accel_str);
-          gtk_label_set_text_with_mnemonic (GTK_LABEL (display->label_accel_label), str);
-          g_free (str);
-        }
-      else
-        {
-          gtk_label_set_text (GTK_LABEL (display->label_accel_label), "");
-        }
-
-      if (info->small_icon)
-        gtk_image_set_from_stock (GTK_IMAGE (display->icon_image), info->id,
-                                  get_largest_size (info->id));
-      else
-        gtk_image_set_from_pixbuf (GTK_IMAGE (display->icon_image), NULL);
-
-      stock_item_info_free (info);
-    }
-  else
-    {
-      gtk_label_set_text (GTK_LABEL (display->type_label), "No selected item");
-      gtk_label_set_text (GTK_LABEL (display->macro_label), "");
-      gtk_label_set_text (GTK_LABEL (display->id_label), "");
-      gtk_label_set_text (GTK_LABEL (display->label_accel_label), "");
-      gtk_image_set_from_pixbuf (GTK_IMAGE (display->icon_image), NULL);
-    }
-}
-
-static void
-macro_set_func_text (GtkTreeViewColumn *tree_column,
-                     GtkCellRenderer   *cell,
-                     GtkTreeModel      *model,
-                     GtkTreeIter       *iter,
-                     gpointer           data)
-{
-  StockItemInfo *info;
-
-  gtk_tree_model_get (model, iter,
-                      0, &info,
-                      -1);
-
-  g_object_set (GTK_CELL_RENDERER (cell),
-                "text", info->macro,
-                NULL);
-
-  stock_item_info_free (info);
-}
-
-static void
-id_set_func (GtkTreeViewColumn *tree_column,
-             GtkCellRenderer   *cell,
-             GtkTreeModel      *model,
-             GtkTreeIter       *iter,
-             gpointer           data)
-{
-  StockItemInfo *info;
-
-  gtk_tree_model_get (model, iter,
-                      0, &info,
-                      -1);
-
-  g_object_set (GTK_CELL_RENDERER (cell),
-                "text", info->id,
-                NULL);
-
-  stock_item_info_free (info);
-}
-
-static void
-accel_set_func (GtkTreeViewColumn *tree_column,
-                GtkCellRenderer   *cell,
-                GtkTreeModel      *model,
-                GtkTreeIter       *iter,
-                gpointer           data)
-{
-  StockItemInfo *info;
-
-  gtk_tree_model_get (model, iter,
-                      0, &info,
-                      -1);
-
-  g_object_set (GTK_CELL_RENDERER (cell),
-                "text", info->accel_str,
-                NULL);
-
-  stock_item_info_free (info);
-}
-
-static void
-label_set_func (GtkTreeViewColumn *tree_column,
-                GtkCellRenderer   *cell,
-                GtkTreeModel      *model,
-                GtkTreeIter       *iter,
-                gpointer           data)
-{
-  StockItemInfo *info;
-
-  gtk_tree_model_get (model, iter,
-                      0, &info,
-                      -1);
-
-  g_object_set (GTK_CELL_RENDERER (cell),
-                "text", info->item.label,
-                NULL);
-
-  stock_item_info_free (info);
-}
-
-GtkWidget *
-do_stock_browser (GtkWidget *do_widget)
-{
-  if (!window)
-    {
-      GtkWidget *frame;
-      GtkWidget *vbox;
-      GtkWidget *hbox;
-      GtkWidget *sw;
-      GtkWidget *treeview;
-      GtkTreeModel *model;
-      GtkCellRenderer *cell_renderer;
-      StockItemDisplay *display;
-      GtkTreeSelection *selection;
-      GtkTreeViewColumn *column;
-
-      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-      gtk_window_set_screen (GTK_WINDOW (window),
-                             gtk_widget_get_screen (do_widget));
-      gtk_window_set_title (GTK_WINDOW (window), "Stock Icons and Items");
-      gtk_window_set_default_size (GTK_WINDOW (window), -1, 500);
-
-      g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
-      gtk_container_set_border_width (GTK_CONTAINER (window), 8);
-
-      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
-      gtk_container_add (GTK_CONTAINER (window), hbox);
-
-      sw = gtk_scrolled_window_new (NULL, NULL);
-      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
-                                      GTK_POLICY_NEVER,
-                                      GTK_POLICY_AUTOMATIC);
-      gtk_box_pack_start (GTK_BOX (hbox), sw, FALSE, FALSE, 0);
-
-      model = create_model ();
-
-      treeview = gtk_tree_view_new_with_model (model);
-
-      g_object_unref (model);
-
-      gtk_container_add (GTK_CONTAINER (sw), treeview);
-
-      column = gtk_tree_view_column_new ();
-      gtk_tree_view_column_set_title (column, "Macro");
-
-      cell_renderer = gtk_cell_renderer_pixbuf_new ();
-      gtk_tree_view_column_pack_start (column,
-                                       cell_renderer,
-                                       FALSE);
-      gtk_tree_view_column_set_attributes (column, cell_renderer,
-                                           "stock_id", 1, NULL);
-      cell_renderer = gtk_cell_renderer_text_new ();
-      gtk_tree_view_column_pack_start (column,
-                                       cell_renderer,
-                                       TRUE);
-      gtk_tree_view_column_set_cell_data_func (column, cell_renderer,
-                                               macro_set_func_text, NULL, NULL);
-
-      gtk_tree_view_append_column (GTK_TREE_VIEW (treeview),
-                                   column);
-
-      cell_renderer = gtk_cell_renderer_text_new ();
-      gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (treeview),
-                                                  -1,
-                                                  "Label",
-                                                  cell_renderer,
-                                                  label_set_func,
-                                                  NULL,
-                                                  NULL);
-
-      cell_renderer = gtk_cell_renderer_text_new ();
-      gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (treeview),
-                                                  -1,
-                                                  "Accel",
-                                                  cell_renderer,
-                                                  accel_set_func,
-                                                  NULL,
-                                                  NULL);
-
-      cell_renderer = gtk_cell_renderer_text_new ();
-      gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (treeview),
-                                                  -1,
-                                                  "ID",
-                                                  cell_renderer,
-                                                  id_set_func,
-                                                  NULL,
-                                                  NULL);
-
-      frame = gtk_frame_new ("Selected Item");
-      gtk_widget_set_valign (frame, GTK_ALIGN_START);
-      gtk_box_pack_end (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
-
-      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
-      gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
-      gtk_container_add (GTK_CONTAINER (frame), vbox);
-
-      display = g_new (StockItemDisplay, 1);
-      g_object_set_data_full (G_OBJECT (treeview),
-                              "stock-display",
-                              display,
-                              g_free); /* free display with treeview */
-
-      display->type_label = gtk_label_new (NULL);
-      display->macro_label = gtk_label_new (NULL);
-      display->id_label = gtk_label_new (NULL);
-      display->label_accel_label = gtk_label_new (NULL);
-      display->icon_image = gtk_image_new_from_pixbuf (NULL); /* empty image */
-
-      gtk_box_pack_start (GTK_BOX (vbox), display->type_label,
-                          FALSE, FALSE, 0);
-
-      gtk_box_pack_start (GTK_BOX (vbox), display->icon_image,
-                          FALSE, FALSE, 0);
-
-      gtk_box_pack_start (GTK_BOX (vbox), display->label_accel_label,
-                          FALSE, FALSE, 0);
-      gtk_box_pack_start (GTK_BOX (vbox), display->macro_label,
-                          FALSE, FALSE, 0);
-      gtk_box_pack_start (GTK_BOX (vbox), display->id_label,
-                          FALSE, FALSE, 0);
-
-      selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
-      gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
-
-      g_signal_connect (selection,
-                        "changed",
-                        G_CALLBACK (selection_changed),
-                        NULL);
-    }
-
-  if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
-  else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
-
-  return window;
-}
index ec7a2eb57ba67416fc5cc823a582933950ea94df..812013c4ed08cbe391008ba707094eb3d378cc1f 100644 (file)
@@ -9,7 +9,7 @@
 
 static GtkWidget *window = NULL;
 
-static void load_stock_items (GtkToolPalette *palette);
+static void load_icon_items (GtkToolPalette *palette);
 static void load_toggle_items (GtkToolPalette *palette);
 static void load_special_items (GtkToolPalette *palette);
 
@@ -35,11 +35,19 @@ canvas_item_new (GtkWidget     *widget,
                  gdouble        y)
 {
   CanvasItem *item = NULL;
-  const gchar *stock_id;
+  const gchar *icon_name;
   GdkPixbuf *pixbuf;
-
-  stock_id = gtk_tool_button_get_stock_id (button);
-  pixbuf = gtk_widget_render_icon_pixbuf (widget, stock_id, GTK_ICON_SIZE_DIALOG);
+  GtkIconTheme *icon_theme;
+  int width;
+
+  icon_name = gtk_tool_button_get_icon_name (button);
+  icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
+  gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &width, NULL);
+  pixbuf = gtk_icon_theme_load_icon (icon_theme,
+                                     icon_name,
+                                     width,
+                                     GTK_ICON_LOOKUP_GENERIC_FALLBACK,
+                                     NULL);
 
   if (pixbuf)
     {
@@ -511,7 +519,7 @@ do_toolpalette (GtkWidget *do_widget)
       /* Add and fill the ToolPalette: */
       palette = gtk_tool_palette_new ();
 
-      load_stock_items (GTK_TOOL_PALETTE (palette));
+      load_icon_items (GTK_TOOL_PALETTE (palette));
       load_toggle_items (GTK_TOOL_PALETTE (palette));
       load_special_items (GTK_TOOL_PALETTE (palette));
 
@@ -626,62 +634,45 @@ do_toolpalette (GtkWidget *do_widget)
 
 
 static void
-load_stock_items (GtkToolPalette *palette)
+load_icon_items (GtkToolPalette *palette)
 {
-  GtkWidget *group_af = gtk_tool_item_group_new ("Stock Icons (A-F)");
-  GtkWidget *group_gn = gtk_tool_item_group_new ("Stock Icons (G-N)");
-  GtkWidget *group_or = gtk_tool_item_group_new ("Stock Icons (O-R)");
-  GtkWidget *group_sz = gtk_tool_item_group_new ("Stock Icons (S-Z)");
-  GtkWidget *group = NULL;
+  GList *contexts;
+  GList *l;
+  GtkIconTheme *icon_theme;
 
-  GtkToolItem *item;
-  GSList *stock_ids;
-  GSList *iter;
+  icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (palette)));
 
-  stock_ids = gtk_stock_list_ids ();
-  stock_ids = g_slist_sort (stock_ids, (GCompareFunc) strcmp);
+  contexts = gtk_icon_theme_list_contexts (icon_theme);
+  for (l = contexts; l; l = g_list_next (l))
+    {
+      gchar *context = l->data;
+      GList *icon_names;
+      GList *ll;
 
-  gtk_container_add (GTK_CONTAINER (palette), group_af);
-  gtk_container_add (GTK_CONTAINER (palette), group_gn);
-  gtk_container_add (GTK_CONTAINER (palette), group_or);
-  gtk_container_add (GTK_CONTAINER (palette), group_sz);
+      GtkWidget *group = gtk_tool_item_group_new (context);
+      gtk_container_add (GTK_CONTAINER (palette), group);
 
-  for (iter = stock_ids; iter; iter = g_slist_next (iter))
-    {
-      GtkStockItem stock_item;
-      gchar *id = iter->data;
+      g_message ("Got context '%s'", context);
+      icon_names = gtk_icon_theme_list_icons (icon_theme, context);
+      icon_names = g_list_sort (icon_names, (GCompareFunc) strcmp);
 
-      switch (id[4])
+      for (ll = icon_names; ll; ll = g_list_next (ll))
         {
-          case 'a':
-            group = group_af;
-            break;
+          GtkToolItem *item;
+          gchar *id = ll->data;
 
-          case 'g':
-            group = group_gn;
-            break;
+          g_message ("Got id '%s'", id);
 
-          case 'o':
-            group = group_or;
-            break;
-
-          case 's':
-            group = group_sz;
-            break;
+          item = gtk_tool_button_new (NULL, NULL);
+          gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), id);
+          gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item), id);
+          gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
         }
 
-      item = gtk_tool_button_new_from_stock (id);
-      gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item), id);
-      gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
-      gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
-
-      if (!gtk_stock_lookup (id, &stock_item) || !stock_item.label)
-        gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), id);
-
-      g_free (id);
+      g_list_free_full (icon_names, g_free);
     }
 
-  g_slist_free (stock_ids);
+  g_list_free_full (contexts, g_free);
 }
 
 static void
@@ -761,22 +752,26 @@ load_special_items (GtkToolPalette *palette)
                            "homogeneous", FALSE, "expand", TRUE,
                            "new-row", TRUE, NULL);
 
-  item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_UP);
+  item = gtk_tool_button_new (NULL, NULL);
+  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-up");
   gtk_tool_item_set_tooltip_text (item, "Show on vertical palettes only");
   gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
   gtk_tool_item_set_visible_horizontal (item, FALSE);
 
-  item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
+  item = gtk_tool_button_new (NULL, NULL);
+  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-next");
   gtk_tool_item_set_tooltip_text (item, "Show on horizontal palettes only");
   gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
   gtk_tool_item_set_visible_vertical (item, FALSE);
 
-  item = gtk_tool_button_new_from_stock (GTK_STOCK_DELETE);
+  item = gtk_tool_button_new (NULL, NULL);
+  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "edit-delete");
   gtk_tool_item_set_tooltip_text (item, "Do not show at all");
   gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
   gtk_widget_set_no_show_all (GTK_WIDGET (item), TRUE);
 
-  item = gtk_tool_button_new_from_stock (GTK_STOCK_FULLSCREEN);
+  item = gtk_tool_button_new (NULL, NULL);
+  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "view-fullscreen");
   gtk_tool_item_set_tooltip_text (item, "Expanded this item");
   gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
   gtk_container_child_set (GTK_CONTAINER (group), GTK_WIDGET (item),
@@ -784,7 +779,8 @@ load_special_items (GtkToolPalette *palette)
                            "expand", TRUE,
                            NULL);
 
-  item = gtk_tool_button_new_from_stock (GTK_STOCK_HELP);
+  item = gtk_tool_button_new (NULL, NULL);
+  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "help-browser");
   gtk_tool_item_set_tooltip_text (item, "A regular item");
   gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
 }
index 48c3f454eefa4b7353ef475d0d42dc80123ff4fd..dc597fee742f0ce652d8ffebcd19fe4423c8f7b3 100644 (file)
@@ -49,10 +49,6 @@ static GtkActionEntry entries[] = {
     "_About", "<control>A",                    /* label, accelerator */
     "About",                                   /* tooltip */
     G_CALLBACK (activate_action) },
-  { "Logo", "demo-gtk-logo",                   /* name, stock id */
-     NULL, NULL,                               /* label, accelerator */
-    "GTK+",                                    /* tooltip */
-    G_CALLBACK (activate_action) },
 };
 static guint n_entries = G_N_ELEMENTS (entries);
 
@@ -135,8 +131,6 @@ static const gchar *ui_info =
 "  <toolbar  name='ToolBar'>"
 "    <toolitem action='Open'/>"
 "    <toolitem action='Quit'/>"
-"    <separator action='Sep1'/>"
-"    <toolitem action='Logo'/>"
 "  </toolbar>"
 "</ui>";